package sist.controller;

import java.util.HashMap;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import sist.bean.EmpBean;
import sist.bean.form1Bean;
import sist.dao.ScottDao;

@Controller
@Component
public class ScottController {
	@Resource(name="scottDao")
	private ScottDao dao;
	
	@RequestMapping(value="empView/empList.do")
	public ModelAndView selectEmp(EmpBean bean)throws Throwable{
		HashMap<Object, Object>map=new HashMap<Object, Object>();
		map.put("ename", bean.getEname());
		map.put("job", bean.getJob());
		ModelAndView mv=new ModelAndView();
		mv.setViewName("empView/empList");
		mv.addObject("list", dao.selectEmpList(map));
		return mv;
	}
	
	@RequestMapping(value="empView/empListIn.do")
	public ModelAndView selectInEmp(EmpBean bean)throws Throwable{
		HashMap<Object, Object>map=new HashMap<Object, Object>();
		String []str={"7369","7902","7499"};
		map.put("empnos", str);
		ModelAndView mv=new ModelAndView();
		mv.setViewName("empView/empList");
		mv.addObject("list", dao.selectEmpInList(map));
		return mv;
	}
	
	@RequestMapping(value="empView/empUpdate.do")
	public String updateEmp(EmpBean bean)throws Throwable{
		dao.updateEmp(bean);
		return "redirect:/empView/empList.do";
	}
	
	@RequestMapping(value="empView/empInfo.do")
	public ModelAndView empInfo(@RequestParam(value="empno",required=true)int empno) throws Throwable{
		ModelAndView mv=new ModelAndView();
		mv.addObject("info", dao.empInfo(empno));
		mv.setViewName("empView/empInfo");
		return mv;
	}
	
	@RequestMapping(value="htmlView/memberInsert.do")
	public String insertMember(form1Bean bean)throws Throwable{
		//dao
		
		System.out.println(bean);
		return "redirect:/htmlView/memberList.do";
	}
	
	@RequestMapping(value="htmlView/memberList.do")
	public ModelAndView memberList()throws Throwable{
		ModelAndView mv=new ModelAndView();
		//dao
		mv.setViewName("htmlView/memberList");
		return mv;
	}
}